<template>
	<div>
		<el-form ref="form" :model="form" label-width="80px" size="mini">
		  <el-form-item label="任务名称">
		    <el-input v-model="form.name" ></el-input>
		  </el-form-item>
		  <el-form-item label="任务描述">
		    <el-input v-model="form.details" ></el-input>
		  </el-form-item>
		  <el-form-item label="所属项目">
			  <el-input v-model="form.project"  :disabled="true"></el-input>
		  </el-form-item>
		
		  <el-form-item label="指派给">
		    <el-input v-model="form.assign"  ></el-input>
		  </el-form-item>
		  <el-form-item label="课时">
		    <el-input v-model="form.classHours" ></el-input>
		  </el-form-item>
		 <el-form-item label="时间选择">
		    <el-date-picker
		          v-model="time"
		          type="datetimerange"
		    			   format="yyyy-MM-dd HH:mm:ss"
		    			   value-format="yyyy-MM-dd HH:mm:ss"
		          range-separator="至"
		          start-placeholder="开始日期"
		          end-placeholder="结束日期">
		        </el-date-picker>
		  </el-form-item>
		 
		
		  <el-form-item>
		    <el-button type="primary" plain @click="save">保存数据</el-button>
		  </el-form-item>
		</el-form>
	</div>
</template>

<script>
import axios from '@/utils/axiosutils.js';
export default {
	name: 'edit',
	props:['editid'],
	data() {
		return {
			time:[],
			form: {
				id:'',
				name:'',
				details:'',
				project:'',
				assign:'',
				stime:'',
				etime:'',
				classHours:'',
				status:''
			},
		};
	},
	components: {
	},
	created() {
		axios.get(
			'/task/getOne',
			response => {
				this.form.id=response.obj.id;
				this.form.name = response.obj.name;
				this.form.details = response.obj.details;
				this.form.project = response.obj.project;
				this.form.assign = response.obj.assign;
				this.form.stime = response.obj.stime;
				this.form.etime = response.obj.etime;
				this.form.classHours = response.obj.classHours;
				this.form.status = this.status;
				
				this.time = [response.obj.stime,response.obj.etime];
				
			}, {
				taskId: this.editid
			}
		);
	},
	methods: {
		save: function() {
			if(this.time[0]!=null&&this.time[1]!=null){
				this.form.stime=this.time[0]
				this.form.etime=this.time[1]
				axios.post(
				'/task/add',
				resp => {
					this.$emit('update:show', false);
					this.$emit('getData');
				},
				this.form
			);
			}else{
				this.$message.warning("时间必须选择")
			}
			
		}
	}
};
</script>
<style scoped></style>
